< previous page page_199 next page >

Page 199
Table 9.6 Codes for Defining Numeric Formats
SymbolPurposeMeaning
0Digit placeholderDisplays the digit or displays 0 if no digit appears in that location.
#Digit placeholderDisplays the digit or displays nothing if no digit appears in that location. This causes leading and trailing zeros to be omitted.
.Decimal separatorIndicates where the decimal point is displayed.
,Thousands separatorIndicates where the separators are displayed.
%Percentage indicatorIndicates where a percent sign is displayed. Also causes the number to be multiplied by 100.
E-, E+, e-, e+Scientific NotationUsing E- or e- displays a minus sign next to negative exponents but displays no sign for positive exponents. Using E+ or e+ displays a sign for any exponent.

Formatting Dates
Another form of data that is often a chore to print is dates. If you specify the Print method with a date, it is displayed in the default format for your systemtypically something like 7/5/98. If you want to display the date in another manner (for example, July 5, 1998), you need to use the Format function. Table 9.7 lists some predefined date and time formats (see Figure 9.7).
Table 9.7 Named Date and Time Formats
Named FormatDescription
General DateShows the date and time if the expression contains both portions. Otherwise, displays either the date or the time.
Long DatePrints the day of the week, the day of the month, the month, and the year.
Medium DatePrints the day of the month, a three-letter abbreviation for the month, and the year.
Short DatePrints the day, month, and yearfor example, 7/5/98.
Long TimePrint hours, minutes, and seconds along with the AM/PM indication.
Medium TimePrints hours and minutes along with AM or PM.
Short TimePrints hours and minutes in military time.

In addition to the named values in Table 9.7, there are many codes available that you can use to create your own date and time formats. For example, the following line of code prints today's date on the form:
Form1.print Format(Now,"mm/dd/yyyy")

 
< previous page page_199 next page >